﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using KVB.Common;
using Customer_Profile.eCard.DBDao;

namespace Customer_Profile.eCard.Agent
{
    public partial class SettleAgentList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindData();
        }
               
        private void BindData()
        {
            DataSet ds = new DataSet();
            try
            {
                ds = SettleAgentDao.getSettleAgentList("Y");

                if (ds != null && ds.Tables.Count > 0)
                {
                    dtgLogList.DataSource = ds.Tables[0];
                    dtgLogList.DataBind();
                }
                else
                {
                    dtgLogList.DataBind();
                }
            }
            catch (Exception ex)
            {
                Log.WriteDefaultLog("operationLogBinddata", ex.ToString());
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            Response.Redirect("SettleAgentAdd.aspx");
        }

        protected void dtgLogList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            dtgLogList.PageIndex = e.NewPageIndex;
            BindData();
        }

        protected void dtgLogList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string id = dtgLogList.DataKeys[e.Row.RowIndex].Values["settle_agent_id"].ToString();
                LinkButton lbAction = (LinkButton)e.Row.Cells[7].Controls[1];
                lbAction.Text = "修改";
                lbAction.Attributes.Add("onclick", "javascript:window.location.href='SettleAgentAdd.aspx?settle_agent_id=" + id + "';return false");
            }
        }
    }
}